package com.sywb.chuangyebao.view;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sywb.chuangyebao.R;
import com.sywb.chuangyebao.contract.MyCommentContract;
import com.sywb.chuangyebao.contract.MyCommentContract.FLAG_DIALOG;
import com.sywb.chuangyebao.view.dialog.AlertDialog;

import org.bining.footstone.widget.PullToRefreshView;

import butterknife.BindView;

/**
 * 我的评论
 * Created by duxl on 2018/5/4.
 */

public class MyCommentActivity extends ActionbarActivity<MyCommentContract.Presenter> implements MyCommentContract.MyCommentView {

    @BindView(R.id.common_recycler)
    RecyclerView commonRecycler;
    @BindView(R.id.common_refresh)
    PullToRefreshView commonRefresh;
    @BindView(R.id.common_nodata_content)
    TextView commonNodataContent;
    @BindView(R.id.common_nodata_icon)
    ImageView commonNodataIcon;
    @BindView(R.id.common_nodata_subtitle)
    TextView commonNodataSubtitle;
    @BindView(R.id.common_nodata)
    RelativeLayout commonNodata;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.layout_recycler_refresh;
    }

    @Override
    public void initView(Bundle bundle) {
        super.initView(bundle);
        setTitle(R.string.my_conment);
    }

    @Override
    public void initPresenter() {
        mPresenter.initPresenter(this);
    }

    @Override
    public PullToRefreshView getPullToRefreshView() {
        return commonRefresh;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return commonRecycler;
    }

    @Override
    public void setNoData(boolean isNoData) {
        commonNodata.setVisibility(isNoData ? View.VISIBLE : View.GONE);
    }

    @Override
    public void showConfirmDialog(final FLAG_DIALOG flag, String msg, final Object... args) {
        AlertDialog alertDialog = AlertDialog.newInstance(null, msg, null, null, false);
        alertDialog.setClickListener(new AlertDialog.OnClickListener() {
            @Override
            public void onClick(int position) {
                if (position == 1) {
                    mPresenter.afterConfirmDialog(flag, args);
                }
            }
        });
        alertDialog.show(getMyFragmentManager(), "MyCommentActivity.showConfirmDialog");
    }
}
